Skip to main content
Ped/NPC Dialogues

Creating dialogues

Define server-side dialogues, add branching response options and connect selections to your own events.

Setup overview

Integration notes

Dialogue location

Create your dialogue definitions inside server/dialogues/*.

Nested responses

Dialogue buttons can contain as many nested response options as needed.

Type interface

Configuration

Dialogue interface

Define the dialogue identity, NPC details, opening message and available response buttons.

Dialogue
---@class CDialogue
---@field id string Unique identifier for the dialogue
---@field name string Ped name
---@field title string Ped title
---@field text string Ped opening message
---@field buttons IDialogueButton[]

Dialogue:new(id, name, title, text)
Configuration

Button interface

Configure response labels, follow-up text, events, navigation and optional conditions.

Button
---@class IDialogueButton
---@field label string
---@field text? string
---@field event? string
---@field close? boolean
---@field goback? boolean
---@field buttons? IDialogueButton[]
---@field condition? fun(playerId: number): boolean

---@param ctx IDialogueButton
function CreateDialogueButton(ctx)
return ctx
end

Example

Configuration

Example dialogue

Create a shopkeeper conversation with direct and nested response options.

Example dialogue
Dialogue:new("example_dialog_id2", "Jane (Item Shop)", "Shopkeeper", "Welcome! How can I assist you?")
:addButton(CreateDialogueButton({
label = "Show me your items for sale.",
close = true,
event = "Talk:Shop:ShowItems"
}))
:addButton(CreateDialogueButton({
label = "Do you have any discounts?",
text = "Yes, we have a special discount on selected items. Check them out!",
buttons = {
CreateDialogueButton({
label = "Great, show me the discounted items.",
close = true,
event = "Talk:Shop:ShowDiscountedItems"
}),
CreateDialogueButton({
label = "I'll take a look, thanks.",
close = true
})
}
}))

RegisterNetEvent("Talk:Shop:ShowItems", function()
local playerId = source
print("Showing items...")
end)
RegisterNetEvent("Talk:Shop:ShowDiscountedItems", function()
local playerId = source
print("Showing discounted items...")
end)